# !/usr/bin/env python3
# -*- coding: utf-8 -*-
# @Time : 2023/4/24 8:53
# @Author : xyjiang1216
# @Email : jiangxuyan@nudt.edu.cn
# @File : write_list_into_json.py
# @Version: OpenPlanner2.0
import json
from typing import List


def write_json(array: List,
               filepath: str):
    """
    将link_set写入topo_filepath对应的文件中
    :param array: 需要写入json文件的数组
    :param filepath: 需要写的json文件路径
    :return: None
    """
    try:
        fd = open(filepath, "w")
    except IOError:
        print("IOError: 文件%s不存在或无法读取该文件" % filepath)
    else:
        result = json.dumps(array,
                            indent=4,
                            ensure_ascii=False)
        fd.write(result)
